package org.noahsark.nsmessenger.security;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

class MD5Calculator extends MDCalculator {

	private MessageDigest mMessageDigest;

	private MD5Calculator(MessageDigest md) throws NoSuchAlgorithmException {
		mMessageDigest = md;
	}

	static MDCalculator getInstance() throws NoSuchAlgorithmException {
		return new MD5Calculator(MessageDigest.getInstance("MD5"));
	}

	@Override
	protected byte[] calculate(byte[] data) {
		mMessageDigest.update(data);

		return mMessageDigest.digest();
	}

}
